/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sun.courier.view;
 // <editor-fold defaultstate="collapsed" desc="Import">                          
import com.sun.courier.DemoProperties;
import com.sun.courier.dal.DepartmentDAL;
import com.sun.courier.dal.EmployeeDAL;
import com.sun.courier.entity.Department;
import com.sun.courier.entity.Employee;
import com.sun.courier.model.ButtonsPanel;
import com.sun.courier.model.ButtonsRenderer;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.swing.ButtonModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import org.apache.commons.io.FileUtils;// </editor-fold>

@DemoProperties(
        value = "Employee",
        category = "Employee Management",
        description = "Magage Employee Information, Including: Insert, Update and Delete",
        sourceFiles = { //                "com/sun/courier/view/EmployeeManagement.java",
})
public class EmployeeManagement extends JPanel {

    private DepartmentDAL dalDep = new DepartmentDAL();
    private EmployeeDAL dalEmpl = new EmployeeDAL();
    private ArrayList<Employee> lstEmpl;
    private ArrayList<Department> lstDept;
    private File fImage;
    private File fPhotoFolder = new File("photo/");

    public EmployeeManagement() {
        createControlPanel();

        if (!fPhotoFolder.exists()) {
            fPhotoFolder.mkdir();
        }
        lstDept = dalDep.getAll();
        loadDepCombobox();
        if (lstDept.size() > 0) {
            lstEmpl = dalEmpl.getByDep(lstDept.get(0).getDepId());
            loadTable();
        }
    }

    private void loadDepCombobox() {
        cbxDeparment.removeAllItems();
        for (Department department : lstDept) {
            cbxDeparment.addItem(department.getDepartmentName());
        }
    }

    private void loadTable() {
        Vector cols = new Vector();
        cols.add("Id");
        cols.add("Name");
        cols.add("Address");
        cols.add("Email");
        cols.add("Phone");
        cols.add("Position");
        cols.add("Action");

        Vector data = new Vector();
        for (Employee item : lstEmpl) {
            Vector row = new Vector();
            row.add(item.getEmpId());
            row.add(item.getEmployeeName());
            row.add(item.getAddress());
            row.add(item.getEmail());
            row.add(item.getPhone());
            row.add(item.getPosition());
            row.add("");
            data.add(row);
        }

        DefaultTableModel tblModel = new DefaultTableModel(data, cols);
        tblItem.setModel(tblModel);
        tblItem.getColumnModel().getColumn(0).setMinWidth(50);
        tblItem.getColumnModel().getColumn(0).setMaxWidth(50);

        tblItem.getColumnModel().getColumn(2).setMinWidth(80);
        tblItem.getColumnModel().getColumn(2).setMaxWidth(80);
        
        tblItem.getColumnModel().getColumn(5).setMinWidth(90);
        tblItem.getColumnModel().getColumn(5).setMaxWidth(90);

        tblItem.getColumnModel().getColumn(6).setCellRenderer(new ButtonsRenderer());
        tblItem.getColumnModel().getColumn(6).setCellEditor(new ActionButton());
    }

    // <editor-fold defaultstate="collapsed" desc="Action">
    class ActionButton extends ButtonsPanel implements TableCellEditor {

        transient protected ChangeEvent changeEvent = null;

        public ActionButton() {
            super();

            //---->
            //DEBUG: view button click -> control key down + edit button(same cell) press -> remain selection color
            MouseListener ml = new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    ButtonModel m = ((JButton) e.getSource()).getModel();
                    if (m.isPressed() && tblItem.isRowSelected(tblItem.getEditingRow()) && e.isControlDown()) {
                        setBackground(tblItem.getBackground());
                    }
                }
            };
            buttons.get(0).addMouseListener(ml);
            buttons.get(0).addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    btnDeleteActionPerformed(ae);
                }
            });
            buttons.get(1).addMouseListener(ml);
            buttons.get(1).addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    btnEditActionPerformed(ae);
                }
            });
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            this.setBackground(table.getSelectionBackground());
            return this;
        }

        @Override
        public Object getCellEditorValue() {
            return "";
        }

        //Copid from AbstractCellEditor
        //protected EventListenerList listenerList = new EventListenerList();
        //transient protected ChangeEvent changeEvent = null;
        @Override
        public boolean isCellEditable(EventObject e) {
            return true;
        }

        @Override
        public boolean shouldSelectCell(EventObject anEvent) {
            return true;
        }

        @Override
        public boolean stopCellEditing() {
            fireEditingStopped();
            return true;
        }

        @Override
        public void cancelCellEditing() {
            fireEditingCanceled();
        }

        @Override
        public void addCellEditorListener(CellEditorListener l) {
            listenerList.add(CellEditorListener.class, l);
        }

        @Override
        public void removeCellEditorListener(CellEditorListener l) {
            listenerList.remove(CellEditorListener.class, l);
        }

        public CellEditorListener[] getCellEditorListeners() {
            return listenerList.getListeners(CellEditorListener.class);
        }

        protected void fireEditingStopped() {
            // Guaranteed to return a non-null array
            Object[] listeners = listenerList.getListenerList();
            // Process the listeners last to first, notifying
            // those that are interested in this event
            for (int i = listeners.length - 2; i >= 0; i -= 2) {
                if (listeners[i] == CellEditorListener.class) {
                    // Lazily create the event:
                    if (changeEvent == null) {
                        changeEvent = new ChangeEvent(this);
                    }
                    ((CellEditorListener) listeners[i + 1]).editingStopped(changeEvent);
                }
            }
        }

        protected void fireEditingCanceled() {
            // Guaranteed to return a non-null array
            Object[] listeners = listenerList.getListenerList();
            // Process the listeners last to first, notifying
            // those that are interested in this event
            for (int i = listeners.length - 2; i >= 0; i -= 2) {
                if (listeners[i] == CellEditorListener.class) {
                    // Lazily create the event:
                    if (changeEvent == null) {
                        changeEvent = new ChangeEvent(this);
                    }
                    ((CellEditorListener) listeners[i + 1]).editingCanceled(changeEvent);
                }
            }
        }
    }// </editor-fold>

    class Dialog extends JDialog {

        public Dialog() {
            ini();
        }
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void ini() {

            jLabelDL4 = new javax.swing.JLabel();
            jToolBarDL1 = new javax.swing.JToolBar();
            edit = new javax.swing.JLabel();
            jLabelDL2 = new javax.swing.JLabel();
            jPanelDL1 = new javax.swing.JPanel();
            ImageIcon = new javax.swing.JLabel();
            jPanelDL2 = new javax.swing.JPanel();
            jLabelDL3 = new javax.swing.JLabel();
            jLabelDL5 = new javax.swing.JLabel();
            jLabelDL6 = new javax.swing.JLabel();
            jLabelDL7 = new javax.swing.JLabel();
            jLabelDL8 = new javax.swing.JLabel();
            jLabelDL9 = new javax.swing.JLabel();
            txIDDL = new javax.swing.JTextField();
            txNameDL = new javax.swing.JTextField();
            txAddressDL = new javax.swing.JTextField();
            txEmailDL = new javax.swing.JTextField();
            txPhoneDL = new javax.swing.JTextField();
            txPositionDL = new javax.swing.JTextField();
            jButton1 = new javax.swing.JButton();
            txImageDL = new javax.swing.JLabel();
            Edit = new javax.swing.JButton();
            btCancel = new javax.swing.JButton();

            jLabelDL4.setText("jLabel4");

            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

            jToolBarDL1.setRollover(true);

            edit.setText("Edit Employee");
            jToolBarDL1.add(edit);
            txIDDL.setEditable(false);
            txImageDL.setFont(new Font("Tahoma", 1, 8));

            jLabelDL2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
            jLabelDL2.setForeground(new java.awt.Color(0, 0, 255));
            jLabelDL2.setText("Update Employee");

            jPanelDL1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

            ImageIcon.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            ImageIcon.setText(" No Image");
            ImageIcon.setBorder(javax.swing.BorderFactory.createEtchedBorder());

            jPanelDL2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

            jLabelDL3.setText("Employee ID:");

            jLabelDL5.setText("Name:");

            jLabelDL6.setText("Address:");

            jLabelDL7.setText("Email:");

            jLabelDL8.setText("Phone:");

            jLabelDL9.setText("Positon:");




            javax.swing.GroupLayout jPanelDL2Layout = new javax.swing.GroupLayout(jPanelDL2);
            jPanelDL2.setLayout(jPanelDL2Layout);
            jPanelDL2Layout.setHorizontalGroup(
                    jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDL2Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelDL5, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelDL3, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelDL6, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelDL7, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelDL8, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelDL9, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addGap(18, 18, 18)
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txIDDL)
                    .addComponent(txNameDL)
                    .addComponent(txAddressDL)
                    .addComponent(txEmailDL)
                    .addComponent(txPositionDL)
                    .addComponent(txPhoneDL))
                    .addContainerGap()));
            jPanelDL2Layout.setVerticalGroup(
                    jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDL2Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDL3)
                    .addComponent(txIDDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDL5)
                    .addComponent(txNameDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDL6)
                    .addComponent(txAddressDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDL7)
                    .addComponent(txEmailDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDL8)
                    .addComponent(txPhoneDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(jPanelDL2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDL9)
                    .addComponent(txPositionDL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(24, Short.MAX_VALUE)));

            jButton1.setText("Choose photo...");
            jButton1.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    buttonActionPerformend(ae);
                }
            });

            javax.swing.GroupLayout jPanelDL1Layout = new javax.swing.GroupLayout(jPanelDL1);
            jPanelDL1.setLayout(jPanelDL1Layout);
            jPanelDL1Layout.setHorizontalGroup(
                    jPanelDL1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDL1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanelDL1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ImageIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelDL1Layout.createSequentialGroup()
                    .addGap(10, 10, 10)
                    .addGroup(jPanelDL1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDL1Layout.createSequentialGroup()
                    .addGap(10, 10, 10)
                    .addComponent(txImageDL))
                    .addComponent(jButton1))))
                    .addGap(34, 34, 34)
                    .addComponent(jPanelDL2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(4, 4, 4)));
            jPanelDL1Layout.setVerticalGroup(
                    jPanelDL1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDL1Layout.createSequentialGroup()
                    .addGroup(jPanelDL1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelDL1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(ImageIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(18, 18, 18)
                    .addComponent(txImageDL))
                    .addComponent(jPanelDL2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(0, 8, Short.MAX_VALUE)));

            Edit.setText("Update");
            Edit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    EditActionPerformed(evt);
                }
            });

            btCancel.setText("Cancel");
            btCancel.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btCancelActionPerformed(evt);
                }
            });


            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBarDL1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelDL2)
                    .addGap(130, 130, 130))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanelDL1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                    .addGap(158, 158, 158)
                    .addComponent(Edit)
                    .addGap(27, 27, 27)
                    .addComponent(btCancel)
                    .addContainerGap(152, Short.MAX_VALUE)));
            layout.setVerticalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                    .addGap(10, 10, 10)
                    .addComponent(jLabelDL2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jPanelDL1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Edit)
                    .addComponent(btCancel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jToolBarDL1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)));

            pack();
        }// </editor-fold>                        

        private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            this.setVisible(false);
        }

        private void buttonActionPerformend(java.awt.event.ActionEvent evt) {
            JFileChooser fileChooser = new JFileChooser();
            int chooser = fileChooser.showOpenDialog(null);
            if (chooser == JFileChooser.APPROVE_OPTION) {
                fImage = fileChooser.getSelectedFile();

                try {
                    BufferedImage bufImg = ImageIO.read(fImage);
                    loadImage2(bufImg);
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        }

        private void EditActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            lblMessage.setText("");

            int row = tblItem.getSelectedRow();
            if (row >= 0) {
                Employee employee = lstEmpl.get(row);
                //getdata
                String empId = txIDDL.getText();
                String name = txNameDL.getText();
                String address = txAddressDL.getText();
                String email = txEmailDL.getText();
                String phone = txPhoneDL.getText();
                String image = txImageDL.getText().trim();
                String position = txPositionDL.getText();
                int depId = cbxDeparment.getSelectedIndex() >= 0 ? lstDept.get(cbxDeparment.getSelectedIndex()).getDepId() : 0;

                //validate
                boolean check = true;
                String message = "";
                if (name.isEmpty()) {
                    check = false;
                    message = "Name is required!";
                    txNameDL.requestFocus();
                }

                if (check && address.isEmpty()) {
                    check = false;
                    message = "Address is required!";
                    txAddressDL.requestFocus();
                }

                if (check && email.isEmpty()) {
                    check = false;
                    message = "Email is required!";
                    txEmailDL.requestFocus();
                }
                
                String regex = "^([\\w-\\.])+@([\\w])+\\.(\\w){2,6}(\\.([\\w]){2,4})*$";
                Pattern p = Pattern.compile(regex);
                Matcher matcher = p.matcher(email);
                if (matcher.find()) {
                    check = true;     
                } else {
                    check = false;
                    JOptionPane.showMessageDialog(null, "Email the wrong structure. Email fail.!");   
                }
            




                if (check && phone.isEmpty()) {
                    check = false;
                    message = "Phone is required!";
                    txPhoneDL.requestFocus();
                }
                
                String regexPhone = "[0-9]";
                Pattern p2 = Pattern.compile(regexPhone);
                Matcher matcher2 = p2.matcher(phone);
                if (matcher2.find()) {
                    check = true;
                } else {
                    check = false;
                    JOptionPane.showMessageDialog(null, "Phone is number. Phone fail.!");   
                }

                if (check && position.isEmpty()) {
                    check = false;
                    message = "Position is required!";
                    txPositionDL.requestFocus();
                }

                if (check && depId == 0) {
                    check = false;
                    message = "Department is required, department list is empty!";
                    cbxDeparment.requestFocus();
                }

                //process
                if (check) {
                    employee.setEmployeeName(name);
                    employee.setAddress(address);
                    employee.setEmail(email);
                    employee.setPhone(phone);
                    employee.setImage(image);
                    employee.setPosition(position);
                    employee.setDepId(depId);
                    check &= dalEmpl.edit(employee);

                    if (check) {
                        JOptionPane.showMessageDialog(null, "Edit employee successful");
                        lstEmpl = dalEmpl.getByDep(depId);
                        loadTable();
                        if (!txImageDL.getText().trim().isEmpty() && txImageDL.toString().length() < 10) {
                            try {
                                FileUtils.copyFileToDirectory(fImage, fPhotoFolder);
                            } catch (Exception ex) {
                                Logger.getLogger(EmployeeManagement.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        } else {
                        }
                        this.setVisible(false);
                    } else {
                        JOptionPane.showMessageDialog(null, "Edit employee fail");
                    }
                } else {
                    lblMessage.setText(message);
                }
            } else {
                JOptionPane.showMessageDialog(null, "You must seleted a employee");
            }
        }
    }

    private void btnAddActionPerformed(ActionEvent evt) {
        lblMessage.setText("");

        //getdata
        String name = txtName.getText();
        String address = txtAddress.getText();
        String email = txtEmail.getText();
        String phone = txtPhone.getText();
        String image = lblPath.getText().trim();
        String position = txtPosition.getText();
        int depId = cbxDeparment.getSelectedIndex() >= 0 ? lstDept.get(cbxDeparment.getSelectedIndex()).getDepId() : 0;

        //validate
        boolean check = true;
        String message = "";
        if (name.isEmpty()) {
            check = false;
            message = "Name is required!";
            txtName.requestFocus();
        }

        if (check && address.isEmpty()) {
            check = false;
            message = "Address is required!";
            txtAddress.requestFocus();
        }

        if (check && email.isEmpty()) {
            check = false;
            message = "Email is required!";
            txtEmail.requestFocus();
        }

        if (check && phone.isEmpty()) {
            check = false;
            message = "Phone is required!";
            txtPhone.requestFocus();
        }

        if (check && position.isEmpty()) {
            check = false;
            message = "Position is required!";
            txtPosition.requestFocus();
        }

        if (check && depId == 0) {
            check = false;
            message = "Department is required, department list is empty!";
            cbxDeparment.requestFocus();
        }

        //process
        if (check) {
           dalEmpl.add(new Employee(name, address, email, phone, image, position, depId));

            if (check) {
                JOptionPane.showMessageDialog(null, "Add employee successful");

                lstEmpl = dalEmpl.getByDep(depId);
                loadTable();
                if (!lblPath.getText().trim().isEmpty()) {
                    try {

                        FileUtils.copyFileToDirectory(fImage, fPhotoFolder);
                    } catch (Exception ex) {
                        Logger.getLogger(EmployeeManagement.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                resetControl();
            } else {
                JOptionPane.showMessageDialog(null, "Add employee fail");
            }
        } else {
            lblMessage.setText(message);
        }
    }

    private void btnEditActionPerformed(ActionEvent evt) {
        Dimension ad = new Dimension(500, 200);
        Dialog dialog = new Dialog();
        int row = tblItem.getSelectedRow();
        if (row >= 0) {
            dialog.setLocation(500, 200);
            dialog.setMaximumSize(ad);
            dialog.setMinimumSize(ad);
            dialog.setVisible(true);
            Employee emp = lstEmpl.get(row);
            txIDDL.setText(emp.getEmpId() + "");
            txNameDL.setText(emp.getEmployeeName());
            txAddressDL.setText(emp.getAddress());
            txEmailDL.setText(emp.getEmail());
            txPhoneDL.setText(emp.getPhone());
            txImageDL.setText(emp.getImage());
            txPositionDL.setText(emp.getPosition());

            if (!emp.getImage().trim().isEmpty()) {
                File file = new File("photo/" + emp.getImage());
                if (file.exists()) {
                    try {
                        loadImage2(ImageIO.read(file));
                    } catch (IOException ex) {
                        Logger.getLogger(EmployeeManagement.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    ImageIcon.setIcon(null);
                }

            }
        }
// <editor-fold defaultstate="collapsed" desc="Code fail">                          
//        lblMessage.setText("");
//
//        int row = tblItem.getSelectedRow();
//        if (row >= 0) {
//            Employee employee = lstEmpl.get(row);
//            //getdata
//            String empId = txtId.getText();
//            String name = txtName.getText();
//            String address = txtAddress.getText();
//            String email = txtEmail.getText();
//            String phone = txtPhone.getText();
//            String image = lblPath.getText().trim();
//            String position = txtPosition.getText();
//            int depId = cbxDeparment.getSelectedIndex() >= 0 ? lstDept.get(cbxDeparment.getSelectedIndex()).getDepId() : 0;
//
//            //validate
//            boolean check = true;
//            String message = "";
//            if (name.isEmpty()) {
//                check = false;
//                message = "Name is required!";
//                txtName.requestFocus();
//            }
//
//            if (check && address.isEmpty()) {
//                check = false;
//                message = "Address is required!";
//                txtAddress.requestFocus();
//            }
//
//            if (check && email.isEmpty()) {
//                check = false;
//                message = "Email is required!";
//                txtEmail.requestFocus();
//            }
//
//            if (check && phone.isEmpty()) {
//                check = false;
//                message = "Phone is required!";
//                txtPhone.requestFocus();
//            }
//
//            if (check && position.isEmpty()) {
//                check = false;
//                message = "Position is required!";
//                txtPosition.requestFocus();
//            }
//
//            if (check && depId == 0) {
//                check = false;
//                message = "Department is required, department list is empty!";
//                cbxDeparment.requestFocus();
//            }
//
//            //process
//            if (check) {
//                employee.setEmployeeName(name);
//                employee.setAddress(address);
//                employee.setEmail(email);
//                employee.setPhone(phone);
//                employee.setImage(image);
//                employee.setPosition(position);
//                employee.setDepId(depId);
//                check &= dalEmpl.edit(employee);
//
//                if (check) {
//                    JOptionPane.showMessageDialog(null, "Edit employee successful");
//
//                    lstEmpl = dalEmpl.getByDep(depId);
//                    loadTable();
//                    if (!lblPath.getText().trim().isEmpty()) {
//                        try {
//                            FileUtils.copyFileToDirectory(fImage, fPhotoFolder);
//                        } catch (Exception ex) {
//                            Logger.getLogger(EmployeeManagement.class.getName()).log(Level.SEVERE, null, ex);
//                        }
//                    }
//                } else {
//                    JOptionPane.showMessageDialog(null, "Edit employee fail");
//                }
//            } else {
//                lblMessage.setText(message);
//            }
//        } else {
//            JOptionPane.showMessageDialog(null, "You must seleted a employee");
//        }
        // </editor-fold>                        
    }

    private void btnDeleteActionPerformed(ActionEvent evt) {
        int row = tblItem.getSelectedRow();
        if (row >= 0) {
            int confirm = JOptionPane.showConfirmDialog(null, "Are you sure delete this?", "Delete", JOptionPane.YES_NO_OPTION);
            if (confirm == JOptionPane.YES_OPTION) {
                boolean check = dalEmpl.delete(lstEmpl.get(row).getEmpId());

                if (check) {
                    JOptionPane.showMessageDialog(null, "Delete employee successful");
                    lstEmpl = dalEmpl.getByDep(lstDept.get(cbxDeparment.getSelectedIndex()).getDepId());
                    loadTable();
                    resetControl();
                } else {
                    JOptionPane.showMessageDialog(null, "Employee are working job. Delete fail.! ");
                }
            }
        } else {
            JOptionPane.showMessageDialog(null, "You must seleted a employee");
        }
    }

    private void tblItemMouseClicked(MouseEvent evt) {
        int row = tblItem.getSelectedRow();
        if (row >= 0) {
            Employee emp = lstEmpl.get(row);
            txtId.setText(emp.getEmpId() + "");
            txtName.setText(emp.getEmployeeName());
            txtAddress.setText(emp.getAddress());
            txtEmail.setText(emp.getEmail());
            txtPhone.setText(emp.getPhone());
            lblPath.setText(emp.getImage());
            txtPosition.setText(emp.getPosition());

            if (!emp.getImage().trim().isEmpty()) {
                File file = new File("photo/" + emp.getImage());
                if (file.exists()) {
                    try {
                        loadImage(ImageIO.read(file));
                    } catch (IOException ex) {
                        Logger.getLogger(EmployeeManagement.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } else {
                    lblImage.setIcon(null);
                }

            }
        }
    }

    private void cbxDepartmentAction(ActionEvent e) {
        int deptId = cbxDeparment.getSelectedIndex() >= 0 ? lstDept.get(cbxDeparment.getSelectedIndex()).getDepId() : 0;
        if (deptId > 0) {
            lstEmpl = dalEmpl.getByDep(deptId);
            loadTable();
            resetControl();
        }
    }

    private void btnBrowserActionPerformed(ActionEvent evt) {
        JFileChooser fileChooser = new JFileChooser();
        int chooser = fileChooser.showOpenDialog(null);
        if (chooser == JFileChooser.APPROVE_OPTION) {
            fImage = fileChooser.getSelectedFile();

            try {
                BufferedImage bufImg = ImageIO.read(fImage);
                loadImage(bufImg);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    private void loadImage(BufferedImage bufImg) {
        lblImage.setIcon(new ImageIcon(bufImg.getScaledInstance(lblImage.getWidth(), lblImage.getHeight(), Image.SCALE_SMOOTH)));
        lblPath.setText(fImage.getName());
    }

    private void loadImage2(BufferedImage bufImg) {
        ImageIcon.setIcon(new ImageIcon(bufImg.getScaledInstance(ImageIcon.getWidth(), ImageIcon.getHeight(), Image.SCALE_SMOOTH)));
        txImageDL.setText(fImage.getName());
    }

    private void resetControl() {
        txtId.setText("");
        txtName.setText("");
        txtAddress.setText("");
        txtEmail.setText("");
        txtPhone.setText("");
        lblPath.setText("");
        txtPosition.setText("");
        lblImage.setIcon(null);
    }
// <editor-fold defaultstate="collapsed" desc="code GUI">                          
    protected void createControlPanel() {
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtAddress = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtId = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtPhone = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txtPosition = new javax.swing.JTextField();
        btnBrowser = new javax.swing.JButton();
        lblImage = new javax.swing.JLabel();
        lblPath = new javax.swing.JLabel();
        btnAdd = new javax.swing.JButton();
        lblMessage = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblItem = new javax.swing.JTable();
        cbxDeparment = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Name:");

        jLabel2.setText("Address:");

        jLabel5.setText("Employee ID:");

        txtId.setEditable(false);

        jLabel3.setText("Email:");

        jLabel6.setText("Phone:");

        jLabel7.setText("Position:");

        btnBrowser.setText("Choose photo ...");
        btnBrowser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBrowserActionPerformed(evt);
            }
        });

        cbxDeparment.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                cbxDepartmentAction(ae);
            }
        });

        lblImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblImage.setText("No Image");
        lblImage.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblPath.setText(" ");

        btnAdd.setText("Add");
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        lblMessage.setForeground(new java.awt.Color(255, 0, 0));
        lblMessage.setText(" ");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(lblImage, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(txtName)
                .addComponent(txtId)
                .addComponent(txtAddress)
                .addComponent(txtEmail)
                .addComponent(txtPhone)
                .addComponent(txtPosition)
                .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(btnBrowser)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblPath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap()));
        jPanel2Layout.setVerticalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel5)
                .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel1)
                .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel2)
                .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel3)
                .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel6)
                .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel7)
                .addComponent(txtPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(btnBrowser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblPath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(0, 0, Short.MAX_VALUE))
                .addComponent(lblImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btnAdd)
                .addComponent(lblMessage))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        tblItem.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][]{
            {},
            {},
            {},
            {}
        },
                new String[]{}));
        tblItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblItemMouseClicked(evt);
            }
        });
        tblItem.setRowHeight(30);
        jScrollPane1.setViewportView(tblItem);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 726, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)));

        jLabel4.setText("Department: ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbxDeparment, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap()));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(cbxDeparment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }//</editor-fold>
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnBrowser;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnEdit;
    private javax.swing.JComboBox cbxDeparment;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblImage;
    private javax.swing.JLabel lblMessage;
    private javax.swing.JTable tblItem;
    private javax.swing.JTextField txtAddress;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtId;
    private javax.swing.JTextField txtName;
    private javax.swing.JTextField txtPhone;
    private javax.swing.JTextField txtPosition;
    private javax.swing.JLabel lblPath;
    //dialog
    private javax.swing.JButton Edit;
    private javax.swing.JLabel ImageIcon;
    private javax.swing.JButton btCancel;
    private javax.swing.JLabel edit;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabelDL2;
    private javax.swing.JLabel jLabelDL3;
    private javax.swing.JLabel jLabelDL4;
    private javax.swing.JLabel jLabelDL5;
    private javax.swing.JLabel jLabelDL6;
    private javax.swing.JLabel jLabelDL7;
    private javax.swing.JLabel jLabelDL8;
    private javax.swing.JLabel jLabelDL9;
    private javax.swing.JPanel jPanelDL1;
    private javax.swing.JPanel jPanelDL2;
    private javax.swing.JToolBar jToolBarDL1;
    private javax.swing.JTextField txAddressDL;
    private javax.swing.JTextField txEmailDL;
    private javax.swing.JTextField txIDDL;
    private javax.swing.JLabel txImageDL;
    private javax.swing.JTextField txNameDL;
    private javax.swing.JTextField txPhoneDL;
    private javax.swing.JTextField txPositionDL;
}